import syscall

var file = 'mock/write.txt'

var fd = syscall.open(file, syscall.O_CREAT | syscall.O_RDWR, 0666)

var write_bytes = syscall.write(fd, 'hello world' as [u8])

print('write bytes: ', write_bytes, '\n')

syscall.seek(fd, 0, syscall.SEEK_SET)

var buf = vec<u8>{len=20}
var len = syscall.read(fd, buf)
buf = buf.slice(0, len)
print('read len: ', len, ', data: ', buf as string, '\n')

syscall.close(fd)
syscall.unlink(file)
